package com.spring.serviceimp.message;

import java.util.List;
import java.util.Map;

import com.hibernate.dao.message.MessageDao;
import com.hibernate.pojo.Message;
import com.spring.service.message.MessageService;
import com.struts.form.MessageForm;
import org.apache.commons.beanutils.BeanUtils;

public class MessageServiceImp implements MessageService
{
	private MessageDao messageDao;
	private boolean bool;
	
	public Map findMessage(String hql,int page)
	{
		return messageDao.findMessage(hql,page);
	}
	
	public boolean saveMessage(MessageForm messageform)
	{
		Message message=new Message();
		try
		{
				BeanUtils.copyProperties(message,messageform);
		}
		catch(Exception e)
		{
			bool=false;
			e.printStackTrace();
		}
		return messageDao.saveMessage(message);
	}
	
	public boolean editMessage(MessageForm messageform)
	{
		return messageDao.editMessage(messageform);
	}
	
	public boolean delMessage(Long id)
	{
		return messageDao.delMessage(id);
	}
	
	/**
	 * batch delete message
	 */
	public boolean deleteBatchMessage(String ids)
	{
		return messageDao.deleteBatchMessage(ids);
	}
	
	/**
	 * display some one message
	 */
	public MessageForm displayMessageInfo(Long id)
	{
		MessageForm messageform=new MessageForm();
		try
		{
			Message message=messageDao.displayMessageInfo(id);
			BeanUtils.copyProperties(messageform,message);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return messageform;
	}
	
	
	/**
	 * DAO object
	 * @return
	 */
	public MessageDao getMessageDao() {
		return messageDao;
	}
	public void setMessageDao(MessageDao messageDao) {
		this.messageDao = messageDao;
	}
}
